<div class="modal-panel">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title">
					用户新增
				</h4>
			</div>
			
			<div class="modal-body">
			<form class="createform">
				<input type='hidden' name='save' value='1'>
				<div class="line">
					<div class="left-48 input-group">
						<span class="input-group-addon">用户姓名</span>
						<input type="text" class="form-control" rule='{"nn":1,"mn":2,"mx":15}' name="name" placeholder="必填，15个汉字以内">
					</div>
					<div class="right-48  input-group">
						<span class="input-group-addon">用户账号</span>
						<input type="text" class="form-control" rule='{"nn":1,"mn":2,"mx":16,"rv":{"pr":"admin:user:uniqname"}}' name="username" placeholder="必填，2-16个字符或汉字">
					</div>
				</div>
				<div class="line">
					<div class="left-48 input-group">
						<span class="input-group-addon">登录密码</span>
						<input type="text" class="form-control" name="password" placeholder="必填，16个字符">
						<span class="input-group-addon"><input type="checkbox" class="defaultpwd"/> 使用默认密码888888（6个8）</span>
					</div>
					<div class="right-48  input-group">
						<span class="input-group-addon">现住址</span>
						<input type="text" class="form-control" name="live_address" rule='{"mx":32}' placeholder="32个字符或汉字">
					</div>
				</div>
				<div class="line">
					<div class="left-48 input-group">
						<span class="input-group-addon">手&nbsp;&nbsp;&nbsp;&nbsp;机</span>
						<input type="text" class="form-control" name="mobile" rule='{"rv":{"pr":"admin:user:uniqname"}}' placeholder="中国国内手机号码">
					</div>
					<div class="right-48 input-group">
						<span class="input-group-addon">邮&nbsp;&nbsp;&nbsp;&nbsp;箱</span>
						<input type="text" class="form-control" name="email" rule='{"rv":{"pr":"admin:user:uniqname"}}' placeholder="64个字符以内">
					</div>
				</div>
				<div class="line">
					<div class="left-48 input-group">
						<span class="input-group-addon">性&nbsp;&nbsp;&nbsp;&nbsp;别</span>
						<select class="form-control" name="sex"><option value="">请选择</option></select>
					</div>
					<div class="right-48 input-group">
						<span class="input-group-addon">出生日期</span>
						<input type="text" class="form-control" name="birth" rule='{"vt":3,"rg":"^[\\d]{4}\\-[\\d]{1,2}\\-[\\d]{1,2}$"}' placeholder="格式 年年年年-月月-日日">
					</div>
				</div>
				<div class="line">
					<div class="input-group">
						<span class="input-group-addon">个人爱好</span>
						<div class="ta-outline"><textarea rows="3" rule='{"mx":500}' name="hobby"></textarea></div>
					</div>
				</div>
			</form>
			</div>
			<div class="modal-footer">
				<button type="reset" class="btn btn-default">重置</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary" >提交</button>
			</div>

		</div><!-- /.modal-content -->
	</div><!-- /.modal -->

<script>
$(document).ready(function(){
	m = getMenuByPermit('admin:user:add');
	if(!m){$("#userI").remove();}
	getData(m.url,'',function(res){if(res.code==200 && res.sex){for(i=0;i<res.sex.length;i++){$("#userI select[name='sex']").append("<option value='"+res.sex[i].value+"'>"+res.sex[i].name+"</option>").end();}}});

	$("#userI .createform").formValidation(); 

	$("#userI button.btn-primary").on('click',function(){
		 _p = $(this).getParentTab();
		 m = getMenuByPermit('admin:user:add');
		 if(m){
			getData(m.url,$("#userI .createform").serialize(),
			function(res){
				if(res.code==200){
					messageBox(res.msg,'用户新增结果',
					function(){
						$("#userI").modal('hide');
						
						$("#userI .createform")[0].reset(); //重置新增表单
						m = getMenuByPermit('admin:user');
						getData(m.url,_p.find("div.searchbar form").serialize(),
							function(res){
								_p.fillListData(res);
							});
					});
				}else {
					messageBox(res.msg,'用户新增结果');
				}
			});
		}
			
	});
	
	$("#userI").on('click','input.defaultpwd',function(){
		
		if($(this).prop("checked")){
			$("#userI input[name='password']").val('888888');
			$("#userI input[name='password']").prop('readonly',true);
		}else{
			$("#userI input[name='password']").prop('readonly',false);
		}
	});
});
</script>
